package com.gmail.wangzdl.graph;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;

public class GraphDemo {

    public void getJPG(String path)
    {
        try {
            File img = new File(path);            
            BufferedImage bufferedImage = ImageIO.read(img);
            System.out.println(bufferedImage.getHeight());
            System.out.println(bufferedImage.getWidth());
            Graphics g = bufferedImage.getGraphics();
            //g.drawBytes(data, offset, length, x, y);
            g.drawLine(20, 20, 100, 100);
            bufferedImage.flush();
            g.dispose();
            ImageIO.write(bufferedImage, "bmp", img);                       
        } catch (FileNotFoundException e) {       
            e.printStackTrace();
        } catch (IOException e) {         
            e.printStackTrace();
    }
        
    }
    public static void main(String args[]){
        GraphDemo Graph = new GraphDemo();
        Graph.getJPG("D:\\QQgirl.jpg");
    }

}
